import request from '@/utils/request'

const roleApi = {
  queryAuthedPermission: '/User/getpermission/'
}

class Service {
  /**
   * @description POST 保存授权菜单权限
   */
  static postAuthPermission(data: any) {
    return request({
      url: roleApi.queryAuthedPermission,
      method: 'POST',
      json: true,
      data
    }).then((res) => {
      return res
    })
  }
  // 获取角色列表
  static getRolelist() {
    return request({
      url: '/User/role/',
      method: 'GET',
      json: true,
    }).then((res) => {
      return res
    })
  }
  // 添加角色
  static CreateRole(data: any) {
    return request({
      url: '/User/role/',
      method: 'POST',
      json: true,
      data
    }).then((res) => {
      return res
    })
  }
  // 修改角色权限
  static UpdRolepermission(data:any) {
    return request({
      url: `/User/role/${data.id}`,
      method: 'PUT',
      json: true,
      data
    }).then((res) => {
      return res
    })
  }
  // 删除角色
  static DeleteRole(id:number) {
    return request({
      url: `/User/role/${id}`,
      method: 'DELETE',
      json: true,
    }).then((res) => {
      return res
    })
  }
  // 添加权限
  static GetMeau() {
    return request({
      url: `/User/Meau/`,
      method: 'GET',
      json: true,
    }).then((res) => {
      return res
    })
  }
  // 添加权限
  static AddMeau(data:any) {
    return request({
      url: `/User/Meau/`,
      method: 'POST',
      json: true,
      data
    }).then((res) => {
      return res
    })
  }
  // 修改权限
  static UpdMeau(data:any) {
    return request({
      url: `/User/Meau/${data.id}`,
      method: 'PUT',
      json: true,
      data
    }).then((res) => {
      return res
    })
  }
  // 修改权限
  static DelMeau(id:any) {
    return request({
      url: `/User/Meau/${id}`,
      method: 'DELETE',
      json: true,
    }).then((res) => {
      return res
    })
  }
}
export default Service
